<!-- 我的关注 -->
<template>
	<view class="page">
		<backTop v-if='showGoTop'></backTop>
		
		<view class="followList" v-if='storeList.length > 0'>
			<block v-for="(item,index) in storeList" :key='index'>
				<view class="flex-box">
					<view class="logoBox">
						<image @click='toUrl("/pages/store/storeIndex?shop_id=" + item.shop_id)' class="logo" @error="item.logo=''" :src="item.logo?$imgUrls(item.logo):staticUrl+'/images/imageLoading.png'" mode="aspectFill"></image>
						<view class="flex-box align-center flState flex-center aft" v-if='item.collect == 1' @click="collect(item.shop_id,index,item.collect)">
							<text class="thmeInfo iconfont icon-guanzhu1"></text>
							<text class="thmeInfo gztxt">已关注</text>
						</view>
						<view class="flex-box align-center flState thmeBg flex-center" :style="{'--color': color}" v-else @click="collect(item.shop_id,index,item.collect)">
							<text class="white iconfont icon-guanzhu1"></text>
							<text class="white gztxt">加关注</text>
						</view>
						<!-- <view class="thmeBgLinear myStore" v-if='vid == item.member_id'>我的店</view> -->
					</view>
					<view class="storeBox flex">
						<view class="flex-box align-center" @click='toUrl("/pages/store/storeIndex?shop_id=" + item.shop_id)'>
							<view class="flex-box align-center flex">
								<text class="thmeTxt storeName lines">{{item.name}}</text>
								<!-- <image class="storelevel"  v-if='item.level_img' :src="imgUrl+item.level_img" mode="aspectFit"></image> -->
							</view>
							<text class="iconfont icon-more thmeInfo"></text>
						</view>
						<view class="flex-box fansBox align-center">
							<text class="iconfont thmeInfo icon-denglu1"></text>
							<text class="thmeInfo">{{item.collect_num}}</text>
						</view>
						<view class="goodsBox">
							<view class="thmeTxt">热门{{ nameDefinition.goodsName }}</view>
							<view class="goodsList">
								<block v-if='item.hot_goods && item.hot_goods.length>0' v-for="(item1,index1) in item.hot_goods" :key='index1'>
									<image @click="toGoods(item1.goods_id)" class="radius" @error="item1.img=''" :src="item1.img?$imgUrls(item1.img):staticUrl+'/images/imageLoading.png'" mode="aspectFill"></image>
								</block>
								<text v-if='!item.hot_goods || item.hot_goods.length < 1' class="thmeInfo">还没有推荐{{ nameDefinition.goodsName }}哦~</text>
							</view>
						</view>
					</view>
				</view>
				<view class="padding1">
					<view class="underline"></view>
				</view>
			</block>
		</view>
		<emptys v-if='noData' :title='"你还没有关注任何"+nameDefinition.storeDefinitionName+"哦"'></emptys>
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	export default {
		data() {
			return {
				staticUrl: this.staticUrl,
				imgUrl: this.imgUrl, 
				showGoTop:false,
				page:1,
				more:false,
				noData:false,
				showBaseline:false,
				storeList: [],//门店列表
			}
		},
		onShow() {
			this.page = 1;
			this.storeList = []
			this.$BarTitle(`${this.nameDefinition.storeDefinitionName}关注`)
			this.getStoreList()
		},
		
		methods: {
			collect(id,index,state){ // 收藏店铺
				this.$http.post({
					url: '/singleSaleApi/store_collect',
					data: {
						store_id: id
					}
				}).then(res => {
					if(res.code == 200){
						if(state == 1){
							this.storeList[index].collect = 0
						}else{
							this.storeList[index].collect = 1
						}
					}else{
						uni.showToast({
							title: res.msg,
							icon:'none'
						})
					}
				})
			},
			getStoreList(){
				this.more = false;
				this.noData = false;
				this.showBaseline = false;
				this.$http.get({
					url: '/singleSaleApi/shopList',
					data: {
						is_collect:1,
						page: this.page,
						pageNum: 10,
					}
				}).then(res => {
					if(res.errcode != 100) return this.$Toast(res.msg)
					const result = res.data || []
					this.storeList = [...this.storeList,...result]
					if(result.length > 9){
						this.page ++;
						this.more = true;
					}
					
					if(!this.storeList || this.storeList.length < 1){
						this.noData = true;
					}
					if(this.storeList.length > 0 && (!result || result.length < 9)){
						this.showBaseline = true
					}
				})
			}
		},
		computed:{
			...mapState(['vid','color','navHeight','System','nameDefinition','share','bid'])
		},
		onPageScroll(e) {
			if (e.scrollTop > 200) {
				this.showGoTop = true
			} else {
				this.showGoTop = false
			}
		},
		onReachBottom() {
			if(this.more){
				this.getStoreList()
			}
		},
	
		
	}
</script>

<style scoped lang="scss">
	.followList{
		>view{
			padding: $uni-page-space;
		}
	}
	.white{color: white;}
	.thmeInfo{color: #999999;}
	.icon-more{font-size: 34rpx;}
	.logoBox{
		margin-right: 20rpx;
		.logo{width: 100rpx;height: 100rpx;border-radius: 50%;margin-bottom: 24rpx;}
		.flState{
			border-radius: 40rpx;
			width: 130rpx;
			height: 44rpx;
			position: relative;
			.icon-guanzhu1{font-size: 28rpx;margin-right: 4rpx;}
			.gztxt{font-size: 20rpx;}
		}
		.aft{
			&::after{position: absolute;content: '';width: 200%;height: 200%;border:1px solid #999999!important;transform: scale(0.5) translate(-100%,-100%);left: 50%;top: 50%;border-radius: 80rpx;}
		}
		.myStore{
			z-index: 2;padding: 0 14rpx;margin-top: 10rpx;
			line-height: 36rpx;color: white;text-align: center;border-radius: 36rpx;
		}
	}
	.storeBox{
		.storeName{font-size: 32rpx;margin-right: 10rpx;font-weight: bold;}
		.storelevel{width: 74rpx;height: 32rpx;margin-right: 20rpx;}
		.fansBox{
			margin: 16rpx 0;
			text{
				font-size: 28rpx;
				margin-right: 6rpx;
			}
		}
		.goodsBox{
			padding: 20rpx;background-color: #F2F2F2;border-radius: 4rpx;position: relative;
			&::after{position: absolute;content: '';border: 16rpx solid transparent;border-bottom-color: #F2F2F2;top: -26rpx;}
			.goodsList{
				max-width: 600rpx;box-sizing: border-box;
				overflow-x: auto;
				margin:14rpx -10rpx -6rpx 0;
				image{
					width: calc(20% - 10rpx);height: calc((100vw - 180rpx)/5 - 20rpx);margin-right: 10rpx;
				}
			}
		}
	}
</style>
